home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 June / CHIP_CD_2004-06.iso / software / miranda_hit / files / mirinstsetup.exe / Miranda Installer 0.0.1.2 / PackageSelector.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-04-20  |  5.5 KB  |  127 lines

  1. /*
  2.     Miranda Installer - Installs nightlies and Miranda addons.
  3.     Copyright (C) 2002-2003 Goblineye Entertainment
  4.  
  5.     Authors: Saar (Tornado) and Kai (kai_b)
  6.  
  7.     This program is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU General Public License as published by
  9.     the Free Software Foundation; either version 2 of the License, or
  10.     (at your option) any later version.
  11.  
  12.     This program is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU General Public License
  18.     along with this program; if not, write to the Free Software
  19.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20. */
  21.  
  22. #pragma once
  23.  
  24. // a custom control used to assist in package selection
  25. // it was either this (fun, learning is cool ;P), ownerdrawing the listview control (hate it), or doing tricks with custom draw (not extensible enough)
  26. // if you're reading this to use this control in your project, you're not in luck, hehe :)
  27. // this control isn't customizable at all, and is very specific to its function and what is needed from it (package selection)
  28. // it might be fun to learn how it works though :)
  29.  
  30. // NOTE that this is a small control (relatively speaking) used for very specific tasks, and that's why error-checking
  31. // is pretty slim in there :)
  32.  
  33. // NOTE the control used to "support" being disabled, but it was removed
  34. // later on (actually, most of it was commented out)
  35. // since it wasn't needed anymore
  36.  
  37. // NOTE control doesn't support sizing or moving of itself (but that shouldn't be too hard to add)
  38.  
  39. // ID of packages and files are simply 0+
  40. #include "MirandaInstaller.h"
  41. #pragma hdrstop
  42.  
  43. #define PACKAGESELECTOR_CLASSNAME "MIPackageSelector"
  44.  
  45. // !!used internally
  46. #define PS_OPTIONALTEXT  Translate("Optional Package")
  47. #define PS_PACKAGESPACE 2 // must be an even number (or problems will occur :))
  48. #define PS_FILEPOS_X 25
  49. #define PS_PACKAGEPOS_X 20
  50. #define PS_PACKAGEPOS_Y 10
  51. #define PSM_SCROLLBARUPDATE (WM_USER+12) // updates scrollbar pos
  52. #define PSM_SCROLLBAR (WM_USER+13) // makes changes to client area and such in regard to new pos (wParam)
  53. // !!done :)
  54.  
  55. // ALL info that is returned from the control **MUST** return the same way it was recieved
  56. // no messing around with it
  57. #define PSM_ADDPACKAGE (WM_USER+5) // add a new package. will be inserted at positon given by wParam, lParam is a pointer to a PS_PACKAGEINFO structure that contains info about the new package. returns unique ID of package
  58. #define PSM_ADDFILE (WM_USER+6) // adds a new file (files are added alphabetically). the package it should be put in is identified by wParam, lParam is a pointer to a PS_FILEINFO structure
  59. #define PSM_SELECTPACKAGE (WM_USER+7) // wParam identifies the package, if lParam is true, the package will be selected, if lParam is false, the package will be un-selected :)
  60. #define PSM_GETPACKAGECOUNT (WM_USER+8) // ... :)
  61. #define PSM_GETPACKAGEINFO (WM_USER+9) // wParam is ID of package, return value is a pointer to the package info (PS_PACKAGEINFO) - the caller can make changes if needed.
  62. #define PSM_GETFILECOUNT (WM_USER+10) // wParam is ID of package
  63. #define PSM_GETFILEINFO (WM_USER+11) // wParam is ID of file in package (wait a sec), lParam is a pointer to a PS_PACKAGEINFO structure returned by PSM_GETPACKAGEINFO (now u got it :)). return value is a pointer to a PS_FILEINFO structure
  64.  
  65. // notifications
  66. // NOTE: PSN_PACKAGESELCHANGE is *NOT* triggered by a PSM_SELECTPACKAGE msg!
  67. #define PSN_PACKAGESELCHANGE (WM_USER+23) // no params. a change in the package selection has happened. sent to parent
  68.  
  69. // file
  70. typedef struct PS_FILEINFO_TYPE
  71. {
  72.     char *lpFilename; // filename (allocated by caller)
  73.     DWORD dwFileSize; // in bytes
  74. } PS_FILEINFO;
  75.  
  76. typedef struct PS_FILELIST_TYPE
  77. {
  78.     char *lpDisplayText; // display name
  79.     PS_FILEINFO fileInfo; // info
  80.     PS_FILELIST_TYPE *next;
  81. } PS_FILELIST;
  82.  
  83.  
  84. // package
  85. typedef struct PS_PACKAGEINFO_TYPE
  86. {
  87.     char *lpTitle; // title (allocated by caller)
  88.     bool fOptional; // is this package optional?
  89.     bool fSelected; // selected?
  90. } PS_PACKAGEINFO;
  91.  
  92. typedef struct PS_PACKAGELIST_TYPE
  93. {
  94.     PS_PACKAGEINFO packageInfo; // info
  95.     WORD wTotalFiles; // internal list keeps of number of files this package contains (size of linked list, in a way)
  96.     DWORD dwTotalSize; // total size (in bytes) of all files
  97.  
  98.     // drawing-related stuff
  99.     char *lpDisplayText; // display text. *may* be different than actual display text - needed
  100.     SIZE TitleSize;
  101.     DWORD dwFlags; // LSB - expanded? 0x2 - hot-tracked?
  102.  
  103.     // other stuff
  104.     PS_FILELIST *pFileList;
  105.     PS_PACKAGELIST_TYPE *next;
  106. } PS_PACKAGELIST;
  107.  
  108. typedef struct PS_CONTROLINFO_TYPE
  109. {
  110.     WORD wPackagesNum; // total number of packages
  111.     WORD wRowHeight; // height of each package. computed.
  112.     WORD wFileHeight; // file height
  113.     WORD wScrollPos; // vertical scroll position
  114.     // fonts, pens, brushes... everything we need to draw stuff :)
  115.     HFONT hTitleFont; // package title brush
  116.     HFONT hPackageInfoFont; // package info font
  117.     HPEN hTitleLine; // pen used to draw title line
  118.     HPEN hTitleUL; // title underline
  119.     HPEN hCBPen; // pen
  120.     HBRUSH hBKBrush; // used to draw the background
  121.     HCURSOR hHandCursor; // needs no releasing
  122. //    HBRUSH hDBKBrush; // used to draw the background when the control is disabled
  123.     PS_PACKAGELIST *pPackageList;
  124. } PS_CONTROLINFO;
  125.  
  126. // Init control
  127. void PackageSelector_Init(void);